//
//  PersonalViewController.m
//  PhotoStudio
//
//  Created by 华谕 on 2017/10/20.
//  Copyright © 2017年 HUYU. All rights reserved.
//

#import "PersonalViewController.h"
#import "UIScrollView+ScalableCover.h"
#import "LoginViewController.h"
#import "DistributionViewController.h"
#import "UserDataViewController.h"
#import "BillingDetailsViewController.h"
#import "SetUpViewController.h"
#import "BankCarViewController.h"
#import "FeedBackViewController.h"
#import "TopupIntegralViewController.h"
#import "AboutUsViewController.h"
#import "UserModel.h"
#import "RSA.h"
#import "OrderManageViewController.h"
#import "JSBadgeView.h"
#import "MessageViewController.h"

static NSString *cellPath = @"personCell";
@interface PersonalViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UIImageView *faceView;
    UILabel *nameLab;
    UIView *lineView;
    UILabel *firstLab;
    UILabel *secondLab;
    UILabel *thirdLab;

}
@property (nonatomic, strong)UITableView *tableview;
@property (nonatomic, strong)UserModel *model;
@property (nonatomic, strong)NSArray *titleArray;
@property (nonatomic, strong)NSArray *imgArray;
@property (nonatomic, strong)NSString *phoneStr;
@property (nonatomic, strong)NSString *firstNumStr;
@property (nonatomic, strong)NSString *secondNumStr;
@property (nonatomic, strong)NSString *thirdNumStr;
@property (nonatomic, strong)UIView *orderView;

@end

@implementation PersonalViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    [self requestGetUserInfo];
    [self requestUserWallet];
    [self requestOrdernumRemind];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;

}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    if (![LTools storageForKey:SERVER_isPass])
    {
        _titleArray = @[@"银行卡管理",@"意见反馈",@"关于我们"];
        _imgArray = @[@"bankGL",@"feedBack",@"aboutUs"];

    }
    else
    {
        _titleArray = @[@"我的分销",@"银行卡管理",@"意见反馈",@"关于我们"];
        _imgArray = @[@"fenxiao",@"bankGL",@"feedBack",@"aboutUs"];
    }
    
    [self requestSystemConfig];
    [self creatUI];
}
- (void)adjustStatusBar
{
    CGFloat heightX = 0;
    CGFloat heightR = 0;
    if (SCREEN_HEIGHT == 812)
    {
        heightX = 34;
    }
    else
    {
        if (STATUS_BAR_BIGGER_THAN_20)
        {
            heightR = 20;
        }
    }
    self.tableview.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TABBAR_HEIGHT-heightX-heightR);
    
}
- (void)creatUI
{
    self.view.backgroundColor = BacksColor;
//    self.navigationController.navigationBar.translucent = NO;
    CGFloat heightX = 0;
    CGFloat heightR = 0;
    if (SCREEN_HEIGHT == 812)
    {
        heightX = 34;
    }
    else
    {
        if (STATUS_BAR_BIGGER_THAN_20)
        {
            heightR = 20;
        }
    }
    
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TABBAR_HEIGHT-heightX-heightR) style:UITableViewStylePlain];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableview.backgroundColor = BacksColor;
    [self.view addSubview:_tableview];
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 370*displaywidth)];
    self.tableview.tableHeaderView = headerView;
    [self.tableview addScalableCoverWithImage:[UIImage imageWithColor:ThemeColor] Height:255*displaywidth];
    UIButton *setUpBtn = [ZCControl createButtonWithFrame:CGRectMake(10*displaywidth, 10*displaywidth, 25*displaywidth, 25*displaywidth) ImageName:@"shezhi" Target:self Action:@selector(setUpBtnAction) Title:nil Font:11.0];
    setUpBtn.backgroundColor = [UIColor clearColor];
    [headerView addSubview:setUpBtn];
    UIButton *CustomerBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-75*displaywidth, 10*displaywidth, 25*displaywidth, 25*displaywidth) ImageName:@"kefuperson" Target:self Action:@selector(CustomerBtnAction) Title:nil Font:11.0];
    CustomerBtn.backgroundColor = [UIColor clearColor];
    [headerView addSubview:CustomerBtn];
    UIButton *mesangeBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-35*displaywidth, 10*displaywidth, 25*displaywidth, 25*displaywidth) ImageName:@"message" Target:self Action:@selector(mesangeBtnAction) Title:nil Font:11.0];
    mesangeBtn.backgroundColor = [UIColor clearColor];
    [headerView addSubview:mesangeBtn];
    
    faceView = [ZCControl createImageViewWithFrame:CGRectMake(SCREEN_WIDTH/2-30*displaywidth, 45*displaywidth, 60*displaywidth, 60*displaywidth) ImageName:@"face"];
    faceView.layer.cornerRadius = 30*displaywidth;
    faceView.layer.masksToBounds = YES;
    [headerView addSubview:faceView];
    
    nameLab  = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 115*displaywidth, SCREEN_WIDTH-30*displaywidth, 20*displaywidth) Font:14.0 Text:@"立即登录" Color:[UIColor whiteColor]];
    nameLab.textAlignment = NSTextAlignmentCenter;
    [headerView addSubview:nameLab];
    lineView = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-35*displaywidth, 136*displaywidth, 70*displaywidth, 1)];
    lineView.backgroundColor = ThemeColor;
    [headerView addSubview:lineView];
    UIButton *loginBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH/2-60*displaywidth, 45*displaywidth, 120*displaywidth, 95*displaywidth) ImageName:nil Target:self Action:@selector(loginAction) Title:nil Font:12.0];
    loginBtn.backgroundColor = [UIColor clearColor];
    [headerView addSubview:loginBtn];
    
    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(12.5*displaywidth, 150*displaywidth, SCREEN_WIDTH-25*displaywidth, 215*displaywidth)];
    whiteView.backgroundColor = [UIColor whiteColor];
    whiteView.layer.cornerRadius = 5*displaywidth;
    whiteView.layer.masksToBounds = YES;
    [headerView addSubview:whiteView];
    UILabel *assetsLab = [ZCControl createLabelWithFrame:CGRectMake(20*displaywidth, 5*displaywidth, 80*displaywidth, 30*displaywidth) Font:13.0 Text:@"我的资产" Color:RGB(54, 54, 54)];
    [whiteView addSubview:assetsLab];
    UILabel *billLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-130*displaywidth, 5*displaywidth, 70*displaywidth, 30*displaywidth) Font:11.0 Text:@"账单明细" Color:RGB(102, 102, 102)];
    billLab.textAlignment = NSTextAlignmentRight;
    [whiteView addSubview:billLab];
    UIImageView *imgV = [ZCControl createImageViewWithFrame:CGRectMake(SCREEN_WIDTH-50*displaywidth, 14*displaywidth, 12*displaywidth, 12*displaywidth) ImageName:@"nextimg"];
    imgV.contentMode = UIViewContentModeScaleAspectFit;
    [whiteView addSubview:imgV];
    UIButton *btn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-130*displaywidth, 0, 105*displaywidth, 40*displaywidth) ImageName:nil Target:self Action:@selector(pushAction) Title:nil Font:12.0];
    btn.backgroundColor = [UIColor clearColor];
    [whiteView addSubview:btn];
    UIView *lineview1 = [[UIView alloc] initWithFrame:CGRectMake(20*displaywidth, 40*displaywidth, SCREEN_WIDTH-45*displaywidth, 1)];
    lineview1.backgroundColor = LinesColor;
    [whiteView addSubview:lineview1];
    
    UILabel *balanceLab = [ZCControl createLabelWithFrame:CGRectMake(20*displaywidth, 40*displaywidth, 60*displaywidth, 25*displaywidth) Font:12.0 Text:@"一类积分" Color:RGB(54, 54, 54)];
    [whiteView addSubview:balanceLab];
    UILabel *integralLab = [ZCControl createLabelWithFrame:CGRectMake(90*displaywidth, 40*displaywidth, 60*displaywidth, 25*displaywidth) Font:12.0 Text:@" 二类积分" Color:RGB(54, 54, 54)];
    [whiteView addSubview:integralLab];
    UILabel *THbalanceLab = [ZCControl createLabelWithFrame:CGRectMake(160*displaywidth, 40*displaywidth, 60*displaywidth, 25*displaywidth) Font:12.0 Text:@" 余额" Color:RGB(54, 54, 54)];
    [whiteView addSubview:THbalanceLab];
    firstLab = [ZCControl createLabelWithFrame:CGRectMake(20*displaywidth, 65*displaywidth, 70*displaywidth, 30*displaywidth) Font:14.0 Text:@"0.00" Color:RGB(255, 111, 28)];
    [whiteView addSubview:firstLab];
    secondLab = [ZCControl createLabelWithFrame:CGRectMake(90*displaywidth, 65*displaywidth, 70*displaywidth, 30*displaywidth) Font:14.0 Text:@"0.00" Color:RGB(255, 111, 28)];
    [whiteView addSubview:secondLab];
    thirdLab = [ZCControl createLabelWithFrame:CGRectMake(160*displaywidth, 65*displaywidth, 70*displaywidth, 30*displaywidth) Font:14.0 Text:@"0.00" Color:RGB(255, 111, 28)];
    [whiteView addSubview:thirdLab];
    
    UIView *lineview2 = [[UIView alloc] initWithFrame:CGRectMake(0, 105*displaywidth, SCREEN_WIDTH-25*displaywidth, 1)];
    lineview2.backgroundColor = LinesColor;
    [whiteView addSubview:lineview2];
    
    UIButton *payBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-145*displaywidth, 62.5*displaywidth, 50*displaywidth, 20*displaywidth) ImageName:nil Target:self Action:@selector(payAction) Title:@"充值" Font:11.0];
    payBtn.backgroundColor = [UIColor whiteColor];
    [payBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
    payBtn.layer.cornerRadius = 2;
    payBtn.layer.masksToBounds = YES;
    payBtn.layer.borderWidth = 1;
    payBtn.layer.borderColor = ThemeColor.CGColor;
    [whiteView addSubview:payBtn];
    
    UIButton *buyBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-85*displaywidth, 62.5*displaywidth, 50*displaywidth, 20*displaywidth) ImageName:nil Target:self Action:@selector(buyBtnAction) Title:@"回购" Font:11.0];
    buyBtn.backgroundColor = [UIColor whiteColor];
    [buyBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
    buyBtn.layer.cornerRadius = 2;
    buyBtn.layer.masksToBounds = YES;
    buyBtn.layer.borderWidth = 1;
    buyBtn.layer.borderColor = ThemeColor.CGColor;
    [whiteView addSubview:buyBtn];
    
    if (![LTools storageForKey:SERVER_isPass])
    {
        integralLab.hidden = YES;
        secondLab.hidden = YES;
        buyBtn.hidden = YES;
        thirdLab.hidden = YES;
        THbalanceLab.hidden = YES;
        payBtn.hidden = YES;
    }
    
    UILabel *orderLab = [ZCControl createLabelWithFrame:CGRectMake(20*displaywidth, 110*displaywidth, 80*displaywidth, 35*displaywidth) Font:13.0 Text:@"我的订单" Color:RGB(54, 54, 54)];
    [whiteView addSubview:orderLab];
    UILabel *allOrderLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-140*displaywidth, 110*displaywidth, 80*displaywidth, 35*displaywidth) Font:11.0 Text:@"查看全部订单" Color:RGB(102, 102, 102)];
    allOrderLab.textAlignment = NSTextAlignmentRight;
    [whiteView addSubview:allOrderLab];
    UIImageView *imgV2 = [ZCControl createImageViewWithFrame:CGRectMake(SCREEN_WIDTH-50*displaywidth, 121*displaywidth, 12*displaywidth, 12*displaywidth) ImageName:@"nextimg"];
    imgV2.contentMode = UIViewContentModeScaleAspectFit;
    [whiteView addSubview:imgV2];
    UIButton *btn2 = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-140*displaywidth, 105, 105*displaywidth, 40*displaywidth) ImageName:nil Target:self Action:@selector(allOrderAction) Title:nil Font:12.0];
    btn2.backgroundColor = [UIColor clearColor];
    [whiteView addSubview:btn2];
    UIView *lineview3 = [[UIView alloc] initWithFrame:CGRectMake(20*displaywidth, 149*displaywidth, SCREEN_WIDTH-45*displaywidth, 1)];
    lineview3.backgroundColor = LinesColor;
    [whiteView addSubview:lineview3];
    self.orderView = [[UIView alloc] initWithFrame:CGRectMake(0, 150*displaywidth, SCREEN_WIDTH-25*displaywidth, 60*displaywidth)];
    _orderView.backgroundColor = [UIColor clearColor];
    [whiteView addSubview:_orderView];
    NSArray *orderImgAry = @[@"dfk01",@"yfk02",@"dfh03",@"ysh04",@"thtk05"];
    NSArray *titAry = @[@"待付款",@"待发货",@"待收货",@"已完成",@"退款"];
    CGFloat W = SCREEN_WIDTH-55*displaywidth;
    for (int i = 0; i < titAry.count; i++)
    {
        UIButton *closebtn = [UIButton buttonWithType:UIButtonTypeCustom];
        closebtn.frame = CGRectMake(15*displaywidth+(W/5)*i, 0, (W/5), 60*displaywidth);
        [closebtn setImage:[UIImage imageNamed:orderImgAry[i]] forState:UIControlStateNormal];
        [closebtn setTitleColor:RGB(54, 54, 54) forState:UIControlStateNormal];
        [closebtn setTitle:titAry[i] forState:UIControlStateNormal];
        closebtn.titleLabel.font = NormalFontWithSize(11.0+fontScale);
        closebtn.backgroundColor = [UIColor clearColor];
        closebtn.tag = 100+i;
        [closebtn addTarget:self action:@selector(closeOrderTypeAction:) forControlEvents:UIControlEventTouchUpInside];
        [_orderView addSubview:closebtn];
        [self setButtonContentCenter:closebtn];
        JSBadgeView *badgeView = [[JSBadgeView alloc] initWithParentView:closebtn alignment:JSBadgeViewAlignmentTopRight];
        badgeView.badgeText = @"";
        badgeView.badgeBackgroundColor = RGB(238, 103, 94);
        badgeView.tag = 1000+i;
        [closebtn addSubview:badgeView];
    }
}

-(void)setButtonContentCenter:(UIButton *) btn
{
    CGSize imgViewSize,titleSize,btnSize;
    UIEdgeInsets imageViewEdge,titleEdge;
    CGFloat heightSpace = 10.0f;
    
    //设置按钮内边距
    imgViewSize = btn.imageView.bounds.size;
    titleSize = btn.titleLabel.bounds.size;
    btnSize = btn.bounds.size;
    
    imageViewEdge = UIEdgeInsetsMake(heightSpace,0.0, btnSize.height -imgViewSize.height - heightSpace, - titleSize.width);
    [btn setImageEdgeInsets:imageViewEdge];
    titleEdge = UIEdgeInsetsMake(imgViewSize.height +heightSpace, - imgViewSize.width, 0.0, 0.0);
    [btn setTitleEdgeInsets:titleEdge];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellPath];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
   
    UIImageView *imgView = [ZCControl createImageViewWithFrame:CGRectMake(15*displaywidth, 17.5*displaywidth, 15*displaywidth, 15*displaywidth) ImageName:_imgArray[indexPath.row]];
    imgView.contentMode = UIViewContentModeScaleAspectFill;
    imgView.layer.masksToBounds = YES;
    [cell.contentView addSubview:imgView];
    UILabel *titLab = [ZCControl createLabelWithFrame:CGRectMake(40*displaywidth, 10*displaywidth, 150*displaywidth, 30*displaywidth) Font:14.0 Text:_titleArray[indexPath.row] Color:RGB(51, 51, 51)];
    [cell.contentView addSubview:titLab];
    UIView *lineView11 = [[UIView alloc] initWithFrame:CGRectMake(15*displaywidth, 49*displaywidth, SCREEN_WIDTH-15*displaywidth, 1*displaywidth)];
    lineView11.backgroundColor = LinesColor;
    [cell.contentView addSubview:lineView11];
    return cell;
}




- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger index = indexPath.row;
    if (![LTools storageForKey:SERVER_isPass])
    {
        index+=1;
    }
    if (index == 0)
    {
        if (![LTools storageForKey:SERVER_IsLogin])
        {
            [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
            return;
        }
        DistributionViewController *vc = [[DistributionViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    else if (index == 1)
    {
        if (![LTools storageForKey:SERVER_IsLogin])
        {
            [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
            return;
        }
        BankCarViewController *vc = [[BankCarViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    else if (index == 2)
    {
        FeedBackViewController *vc = [[FeedBackViewController alloc] init];
        vc.pladerStr = @"请输入遇到的问题或建议...";
        vc.titleStr = @"意见反馈";
        [self.navigationController pushViewController:vc animated:YES];
    }
    else if (index == 3)
    {
        AboutUsViewController *vc = [[AboutUsViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50*displaywidth;
}

//设置
- (void)setUpBtnAction
{
    if (![LTools storageForKey:SERVER_IsLogin])
    {
        [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
        return;
    }
    SetUpViewController *vc = [[SetUpViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
//客服
- (void)CustomerBtnAction
{
    if (_phoneStr.length > 0)
    {
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",_phoneStr]]];
    }
    else
    {
        [self requestSystemConfig];
    }
}
//消息
- (void)mesangeBtnAction
{
    if (![LTools storageForKey:SERVER_IsLogin])
    {
        [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
        return;
    }
    MessageViewController *vc = [[MessageViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
}

//登录
- (void)loginAction
{
    if ([LTools storageForKey:SERVER_IsLogin])
    {
        UserDataViewController *vc = [[UserDataViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    else
    {
        LoginViewController *vc = [[LoginViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

//账单明细
- (void)pushAction
{
    if (![LTools storageForKey:SERVER_IsLogin])
    {
        [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
        return;
    }
    BillingDetailsViewController *vc = [[BillingDetailsViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
//充值
- (void)payAction
{
    if (![LTools storageForKey:SERVER_IsLogin])
    {
        [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
        return;
    }
    TopupIntegralViewController *vc = [[TopupIntegralViewController alloc] init];
    vc.isHuiGou = NO;
    [self.navigationController pushViewController:vc animated:YES];
}
//回购
- (void)buyBtnAction
{
    if (![LTools storageForKey:SERVER_IsLogin])
    {
        [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
        return;
    }
    TopupIntegralViewController *vc = [[TopupIntegralViewController alloc] init];
    vc.isHuiGou = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
//全部订单
- (void)allOrderAction
{
    if (![LTools storageForKey:SERVER_IsLogin])
    {
        [LTools showMBProgressWithText:@"请先登录" addToView:self.view];
        return;
    }
    OrderManageViewController *vc = [[OrderManageViewController alloc] init];
    vc.orderType = 0;
    vc.TypeString = @"";
    [self.navigationController pushViewController:vc animated:YES];

}

- (void)closeOrderTypeAction:(UIButton *)btn
{
    NSInteger index = btn.tag-99;
    OrderManageViewController *vc = [[OrderManageViewController alloc] init];
    vc.orderType = index;
    NSArray *typeAry = @[@"",@"100",@"110",@"120",@"200",@"130"];
    vc.TypeString = typeAry[index];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)requestGetUserInfo
{
    WEAKSELF;
    [HYBaseHandler requestGetUserInfoParmers:nil Success:^(id obj)
    {
        if ([obj server_Getcodecheck])
        {
            _model = [UserModel mj_objectWithKeyValues:obj[@"data"]];
            [LTools storage:YES ForKey:SERVER_IsLogin];
            [LTools cache:_model.phone ForKey:SERVER_Phone];
            [LTools cache:_model.provinceId ForKey:SERVER_sheng];
            [LTools cache:_model.cityId ForKey:SERVER_shi];
            [LTools cache:_model.districtId ForKey:SERVER_qu];
            [LTools cache:_model.provinceText ForKey:SERVER_shengName];
            [LTools cache:_model.cityText ForKey:SERVER_shiName];
            [LTools cache:_model.districtText ForKey:SERVER_quName];
            dispatch_async(dispatch_get_main_queue(), ^{
                if (_model.nickname.length > 0)
                {
                    nameLab.text = _model.nickname;
                }
                else
                {
                    nameLab.text = _model.phone;
                }
                if (_model.imgUrl.length > 0)
                {
                    [faceView sd_setImageWithURL:[NSURL URLWithString:_model.imgUrl] placeholderImage:[UIImage imageNamed:@"face"]];
                }
                lineView.hidden = YES;
                
                
            });
        }
        else
        {
            if (![LTools storageForKey:SERVER_IsLogin])
            {
                dispatch_async(dispatch_get_main_queue(), ^{
                    faceView.image = [UIImage imageNamed:@"face"];
                    nameLab.text = @"立即登录";
                    lineView.hidden = NO;
                    firstLab.text = @"0.00";
                    secondLab.text = @" 0.00";
                });
            }
            if ([obj[@"msg"] isEqualToString:@"用户 已被冻结"])
            {
                [LTools storage:NO ForKey:SERVER_IsLogin];
                [LTools cache:@"" ForKey:SERVER_LoginToken];
                LoginViewController *vc = [[LoginViewController alloc] init];
                [self.navigationController pushViewController:vc animated:YES];
                [LTools showMBProgressWithText:@"用户 已被冻结" addToView:sharedDelegate.window];
            }
            
        }
    } failed:^(NSError *error) {
        
    }];
}

//客服
- (void)requestSystemConfig
{
    WEAKSELF;
    NSDictionary *dic = @{@"keys":@"server_phone"};
    [HYBaseHandler requestSystemConfigParmers:dic Success:^(id obj) {
        if ([obj server_Getcodecheck])
        {
            NSString *phone = obj[@"data"][@"server_phone"];
            weakSelf.phoneStr = [NSString stringWithFormat:@"%@",phone];
        }
        else
        {
            [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
        }
    } failed:^(NSError *error) {
        
    }];
}

//我的积分
- (void)requestUserWallet
{
    WEAKSELF;
    [HYBaseHandler requestUserWalletParmers:nil Success:^(id obj) {
        if ([obj server_Getcodecheck])
        {
            NSString *oneIntegral = obj[@"data"][@"oneIntegral"];
            NSString *twoIntegral = obj[@"data"][@"twoIntegral"];
            NSString *threeIntegral = obj[@"data"][@"preferenceBalance"];

            dispatch_async(dispatch_get_main_queue(), ^{
                firstLab.text = [NSString stringWithFormat:@"%.2lf",[oneIntegral floatValue]];
                secondLab.text = [NSString stringWithFormat:@"%.2lf",[twoIntegral floatValue]];
                thirdLab.text = [NSString stringWithFormat:@"%.2lf",[threeIntegral floatValue]];
            });
            
        }
        else
        {
            [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
        }
    } failed:^(NSError *error) {
        
    }];
}

//数量查询
- (void)requestOrdernumRemind
{
    WEAKSELF;
    [HYBaseHandler requestOrdernumRemindParmers:nil Success:^(id obj) {
        if ([obj server_Getcodecheck])
        {
            weakSelf.firstNumStr = obj[@"data"][@"waitPay"];
            weakSelf.secondNumStr = obj[@"data"][@"waitDeliver"];
            weakSelf.thirdNumStr = obj[@"data"][@"waitReceipt"];
            dispatch_async(dispatch_get_main_queue(), ^{
                NSArray *numAry = @[weakSelf.firstNumStr,weakSelf.secondNumStr,weakSelf.thirdNumStr];
                for (int i = 0; i < 3; i++)
                {
                    UIButton *btn = (UIButton *)[weakSelf.orderView viewWithTag:100+i];
                    JSBadgeView *jsview = (JSBadgeView *)[btn viewWithTag:1000+i];
                    NSString *numStr = s_str(numAry[i]);
                    if ([numStr integerValue] == 0)
                    {
                        jsview.badgeText = @"";
                    }
                    else
                    {
                        jsview.badgeText = numStr;
                    }
                }
                
            });
            
            
        }
        else
        {
            [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
        }
    } failed:^(NSError *error) {
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
